/*
 * *******************************************************************
 *   @项目名称: BHex Android
 *   @文件名称: PointCardApi.java
 *   @Date: 18-11-30 下午3:22
 *   @Author: ppzhao
 *   @Description:
 *   @Copyright（C）: 2018 BlueHelix Inc.   All rights reserved.
 *   注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目的.
 *  *******************************************************************
 */

package io.bhex.sdk.point;

import io.bhex.baselib.network.BParamsBuilder;
import io.bhex.baselib.network.HttpUtils;
import io.bhex.baselib.network.listener.SimpleResponseListener;
import io.bhex.baselib.network.params.GetParams;
import io.bhex.baselib.network.params.PostParams;
import io.bhex.sdk.Urls;
import io.bhex.sdk.point.bean.AdvertisementListResponse;
import io.bhex.sdk.point.bean.AppPointCardListResponse;
import io.bhex.sdk.point.bean.BuyPointResponse;
import io.bhex.sdk.point.bean.PointBalanceFlowResponse;
import io.bhex.sdk.point.bean.PointBalanceResponse;
import io.bhex.sdk.point.bean.PointBuyFlowResponse;
import io.bhex.sdk.point.bean.PointCardBalanceListResponse;
import io.bhex.sdk.point.bean.PointCardBean;
import io.bhex.sdk.point.bean.PointCardEventResponse;
import io.bhex.sdk.point.bean.PointCardListResponse;
import io.bhex.sdk.point.bean.PointCardPackageDetail;
import io.bhex.sdk.point.bean.PointRuleResponse;

public class PointCardApi {

    /**
     * 购买点卡
     * @param accountId
     * @param brokerId
     * @param pointPackId
     * @param quantity
     * @param payTokenId
     * @param channel
     * @param listener
     */
    public static void requestBuyPointCard(String accountId,String brokerId,String pointPackId,String quantity,String payTokenId,String channel,SimpleResponseListener<BuyPointResponse> listener){
        PostParams params = BParamsBuilder.post()
                .url(Urls.API_POINTCARD_BUY)
                .addParam("account_id", accountId)
                .addParam("broker_id", brokerId)
                .addParam("point_pack_id", pointPackId)
                .addParam("quantity", quantity)
                .addParam("pay_token_id", payTokenId)
                .addParam("channel", channel)
                .build();

        HttpUtils.getInstance().request(params, BuyPointResponse.class, listener);
    }

    /**
     * 购买记录
     * @param accountId
     * @param pageFromId
     * @param pageEndId
     * @param limit
     * @param listener
     */
    public static void requestBuyPointCardFlow(String accountId,String pageFromId,String pageEndId,String limit,SimpleResponseListener<PointBuyFlowResponse> listener){
        GetParams params = BParamsBuilder.get()
                .url(Urls.API_POINTCARD_BUY_FLOW)
                .addParam("account_id", accountId)
                .addParam("from_flow_id", pageFromId)
                .addParam("end_flow_id", pageEndId)
                .addParam("limit", limit)
                .build();

        HttpUtils.getInstance().request(params, PointBuyFlowResponse.class, listener);
    }

    /**
     * 点卡明细
     * @param accountId
     * @param pageFromId
     * @param pageEndId
     * @param limit
     * @param listener
     */
    public static void requestPointCardBalanceFlow(String accountId,String pageFromId,String pageEndId,String limit,SimpleResponseListener<PointBalanceFlowResponse> listener){
        GetParams params = BParamsBuilder.get()
                .url(Urls.API_POINTCARD_BALANCE_FLOW)
                .addParam("account_id", accountId)
                .addParam("from_flow_id", pageFromId)
                .addParam("end_flow_id", pageEndId)
                .addParam("limit", limit)
                .build();

        HttpUtils.getInstance().request(params, PointBalanceFlowResponse.class, listener);
    }


    /**
     * 余额（我的点卡）
     * @param accountId
     * @param pointTokenId
     * @param listener
     */
    public static void requestPointCardBalance(String accountId,String pointTokenId,SimpleResponseListener<PointBalanceResponse> listener){
        GetParams params = BParamsBuilder.get()
                .url(Urls.API_POINTCARD_BALANCE)
                .addParam("account_id", accountId)
                .addParam("point_token_id", pointTokenId)
                .build();

        HttpUtils.getInstance().request(params, PointBalanceResponse.class, listener);
    }


    /**
     * 点卡余额列表（点卡分类型）
     * @param listener
     * todo
     */
    public static void requestPointCardBalanceList(SimpleResponseListener<PointCardBalanceListResponse> listener){
        GetParams params = BParamsBuilder.get()
                .url(Urls.API_POINTCARD_BALANCE_LIST)
                .build();

        HttpUtils.getInstance().request(params, PointCardBalanceListResponse.class, listener);
    }

    /**
     * 点卡列表（点卡分类型）
     * @param listener
     * todo
     */
    public static void requestPointCardList(SimpleResponseListener<AppPointCardListResponse> listener){
        GetParams params = BParamsBuilder.get()
                .url(Urls.API_POINTCARD_PACKAGE_LIST)
                .build();

        HttpUtils.getInstance().request(params, AppPointCardListResponse.class, listener);
    }

    /**
     * 点卡商品列表
     * @param brokerId
     * @param listener
     */
    public static void requestPointCardList(String brokerId,SimpleResponseListener<PointCardListResponse> listener){
        GetParams params = BParamsBuilder.get()
                .url(Urls.API_POINTCARD_LIST)
                .addParam("broker_id", brokerId)
                .build();

        HttpUtils.getInstance().request(params, PointCardListResponse.class, listener);
    }

    /**
     * 点卡详情
     * @param pointPackId 点卡套餐id
     * @param listener
     */
    public static void requestPointCardDetail(String pointPackId,SimpleResponseListener<PointCardPackageDetail> listener){
        GetParams params = BParamsBuilder.get()
                .url(Urls.API_POINTCARD_PACKAGE_ITEM_DETAIL)
                .addParam("id", pointPackId)
                .build();

        HttpUtils.getInstance().request(params, PointCardPackageDetail.class, listener);
    }

    /**
     * 活动相关信息
     * @param brokerId 券商id
     * @param listener
     */
    public static void requestPointCardEvent(String brokerId,SimpleResponseListener<PointCardEventResponse> listener){
        GetParams params = BParamsBuilder.get()
                .url(Urls.API_POINTCARD_EVENT)
                .addParam("broker_id", brokerId)
                .build();

        HttpUtils.getInstance().request(params, PointCardEventResponse.class, listener);
    }

    /**
     * 广告列表接口
     * @param listener
     */
    public static void requestAdvertisementList(SimpleResponseListener<AdvertisementListResponse> listener){
        GetParams params = BParamsBuilder.get()
                .url(Urls.API_ADVERTISEMENT_LIST)
                .addParam("locale", "zhcn")
                .build();

        HttpUtils.getInstance().request(params, AdvertisementListResponse.class, listener);
    }
    /**
     * 点卡规则
     * @param locale 语言 zhcn,en
     * @param listener
     */
    public static void requestPointCardRule(String locale,SimpleResponseListener<PointRuleResponse> listener){
        GetParams params = BParamsBuilder.get()
                .url(Urls.API_POINT_RULE)
                .addParam("key", "POINT_CARD_ROLE_LANGUAGE_KEY")
                .addParam("locale", locale)
                .build();

        HttpUtils.getInstance().request(params, PointRuleResponse.class, listener);
    }
}
